package com.woniuxy.config;

import com.woniuxy.filter.AuthFilter;
import com.woniuxy.filter.CrossOriginFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.Arrays;
/**
 * 跨域过滤器必须顺位第一，否则会跨域错误。
 * */
//@Configuration
public class FilterConfig {

//    @Resource
//    private AuthFilter authFilter;

//    @Resource
//    private CrossOriginFilter crossOriginFilter;

//    @Bean
//    public FilterRegistrationBean<AuthFilter> authFilterFilterRegistrationBean1(){
//        FilterRegistrationBean<AuthFilter> bean = new FilterRegistrationBean<>();
//        bean.setFilter(authFilter);
//        bean.setUrlPatterns(Arrays.asList("/*"));  // 过滤所有请求
//        bean.setOrder(2);
//        return bean;
//    }

//    @Bean
//    public FilterRegistrationBean<CrossOriginFilter> authFilterFilterRegistrationBean2(){
//        // crossOriginFilter 是跨域过滤器
//        FilterRegistrationBean<CrossOriginFilter> bean = new FilterRegistrationBean<>();
//        bean.setFilter(crossOriginFilter);
//        bean.setUrlPatterns(Arrays.asList("/*"));  // 过滤所有请求
//        bean.setOrder(1);  // 过滤器的顺序，数字越小，顺序越靠前
//        return bean;
////    }


}